import { FormSchema } from '@/components/Form';
import { BasicColumn } from '@/components/Table';
import { DescItem } from '@/components/Description';
import { DicSortEnum } from '@/enums';

/** 表格数据 */
export const columns: BasicColumn[] = [
  {
    title: '父类型ID',
    dataIndex: 'parentId',
    width: 220,
  },
  // {
  //   title: '树层级',
  //   dataIndex: 'level',
  //   width: 220,
  // },
  {
    title: '分类名称',
    dataIndex: 'typeName',
    width: 220,
  },
];

/** 查询数据 */
export const searchFormSchema: FormSchema[] = [
  {
    label: '分类名称',
    field: 'typeName',
    component: 'Input',
    colProps: { span: 6 },
  },
];

/** 表单数据 */
export const formSchema: FormSchema[] = [
  {
    label: '主键ID',
    field: 'id',
    component: 'Input',
    show: false,
    colProps: { span: 12 },
  },
  {
    label: '父类型ID',
    field: 'parentId',
    component: 'TreeSelect',
    componentProps: {
      showSearch: true,
      treeNodeFilterProp: 'title',
      fieldNames: {
        label: 'typeName',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
    required: true,
    colProps: { span: 24 },
  },
  {
    label: '树层级',
    field: 'level',
    component: 'InputNumber',
    defaultValue: DicSortEnum.ZERO,
    colProps: { span: 12 },
  },
  {
    label: '分类名称',
    field: 'typeName',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
];

/** 详情数据 */
export const detailSchema: DescItem[] = [
  {
    label: '父类型ID',
    field: 'parentId',
    span: 12,
  },
  {
    label: '树层级',
    field: 'level',
    span: 12,
  },
  {
    label: '分类名称',
    field: 'typeName',
    span: 12,
  },
];
